# Load libraries
library(tidyverse)
library(dplyr)
library(stringr)
library(lubridate)
library(sf)
library(leaflet)
library(leafpop)
library(htmltools)
library(scales)
library(highcharter)
library(reactable)
varnames <- c('Company',
'Developer',
'Application...Job..',
'PV..kWAC.',
'Metering..NA...NM...RNM...CDG.',
'Application.Approved.Date...Utility.',
'Project.Complete..Y.N.',
'Zip.Code')
varreplace <- c('utility',
'developer',
'id',
'capacity',
'metering',
'date',
'complete',
'zip')
ny <- do.call(rbind,
lapply(list.files(path = "raw data/NY/solar"), read.csv)) %>%
select(varnames) %>%
rename_at(vars(varnames), ~varreplace) %>%
mutate(date = dmy(date),
capacity = as.numeric(capacity),
quarter = zoo::as.yearqtr(date, format = "%Y-%m-%d"),
utility = case_when(
utility == 'CECONY' ~ 'ConEd',
utility == 'NIMO' ~ 'Niagara Mohawk (NatGrid)',
TRUE ~ utility),
metering = as.factor(case_when(
is.na(metering) | metering == 'n/a' ~ 'Non-Metered',
metering == 'NM' ~ 'Net Metered',
metering == 'RNM' ~ 'Remote Net Metered',
metering == 'FIT' ~ 'Feed-In Tariff',
metering == 'CDG' ~ 'Community Solar',
TRUE ~ 'Other')),
segment_x = case_when(
metering == 'Community Solar' ~ 'Community Solar',
capacity <= 20 ~ 'Residential',
capacity > 20 ~ 'Non-Residential'
)) %>%
filter(!is.na(capacity))
ny_quarter <- ny %>%
filter(date >= '2020-07-01',
quarter != '2021 Q3') %>%
group_by(segment_x, quarter) %>%
summarise(cap = sum(capacity)/1000)
ny_seg <- ny %>%
filter(quarter == '2021 Q2') %>%
mutate(res_cap = if_else(segment_x == 'Residential', capacity, 0),
com_cap = if_else(segment_x == 'Non-Residential', capacity, 0),
cs_cap = if_else(segment_x == 'Community Solar', capacity, 0),
# month = months(as.Date(date)))
month = month(date))
New York added round(sum(ny_seg$capacity)/1000,2) MW of new distributed solar capacity to the interconnection queue in Q2 2021
ny_quarter %>%
hchart('column', hcaes(x = as.factor(quarter), y = round(cap,2), group = segment_x)) %>%
hc_colors(c('#F37325', '#2490BD', "#47B970", '#1A2B40', '#b7b7b7', '#800000','#F8AA1A')) %>%
hc_plotOptions(series = list(stacking = 'normal')) %>%
hc_xAxis(title = '', labels = list(step = 1) #, minorTickInterval
) %>%
hc_yAxis(title = list(text = 'Quarterly capacity (MW)'), style = list(fontSize = "5.0vh"))
Of this round(sum(ny_seg$capacity/1000),2) MW of new capacity…
ny_meter <- ny %>%
group_by(metering) %>%
summarise(cap = sum(capacity))
for (k in levels(ny_meter$metering)) {
cat("- ", "**", round(ny_meter$cap[ny_meter$metering == k]/1000,2), "**", " MW was ", k, sep = "")
cat("\n")
}
- 5718.41 MW was Community Solar
- 91.21 MW was Feed-In Tariff
- 1442.11 MW was Net Metered
- 52.94 MW was Non-Metered
- 4.07 MW was Other
- 461.93 MW was Remote Net Metered
ny %>%
group_by(metering) %>%
summarise(cap = sum(capacity)) %>%
hchart('pie', hcaes(x = metering, y = round(cap/1000,2)), name = "Capacity (MW)") %>%
hc_colors(c( '#2490BD', '#F37325', "#47B970", '#1A2B40', '#b7b7b7', '#F8AA1A', '#800000'))
Where was new capacity added in Q2 2021?
ny_map <- ny %>%
mutate(geoid2 = as.numeric(substr(zip,1,5))) %>%
filter(!geoid2 == 16807|!geoid2 == 17047) %>%
group_by(geoid2) %>%
summarise(cap = sum(capacity)/1000)
nymap <- st_read('raw data/NY/acs2019_5yr_B01003_86000US14475.shp') %>%
mutate(geoid2 = as.numeric(substr(geoid,8,12))) %>%
filter(!name == 'New York') %>%
left_join(ny_map, by = 'geoid2')
zip <- read.csv('raw data/uszips.csv') %>%
select(zip, city) %>%
rename('geoid2' = 'zip')
ny_int <- left_join(nymap, zip, by = 'geoid2') %>%
mutate(cap = round(cap*1000,0),
cap2 = if_else(is.na(cap),0,cap))
map_pal <- c('#e0f1f9', '#2490BD')
pal <- colorNumeric(palette = map_pal, domain = ny_int$cap, na.color = '#FFFFFF')
labels <- sprintf("<strong>%s</strong><br/> Zip code: %s<br/> Capacity Q2 2021: %s kW",
ny_int$city, paste(0, ny_int$geoid2, sep = ""), comma(ny_int$cap2)) %>%
lapply(HTML)
map_int <- leaflet(ny_int) %>% addTiles()
map_int %>% addPolygons(fillColor = ~pal(cap),
weight = 0.5,
opacity = 1,
color = "gray",
dashArray = "3",
fillOpacity = 0.7,
highlightOptions = highlightOptions(color = '#2a2a2a',
weight = 2,
dashArray = "",
fillOpacity = 0.7,
bringToFront = T),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto",
opacity = 0.75)) %>%
addProviderTiles('Esri.WorldGrayCanvas')